using UnityEngine;

namespace Delta2DGame.Base
{
    /// <summary>
    /// 敌人状态基类
    /// </summary>
    public abstract class EnemyState
    {
        protected EnemyStateMachine stateMachine;
        protected EnemyController enemy;
        protected Animator animator;
        protected string animBoolName;

        public EnemyState(EnemyStateMachine stateMachine, EnemyController enemy, string animBoolName)
        {
            this.stateMachine = stateMachine;
            this.enemy = enemy;
            this.animBoolName = animBoolName;
            this.animator = enemy.GetComponent<Animator>();
        }

        /// <summary>
        /// 进入状态时调用
        /// </summary>
        public virtual void Enter()
        {
            animator.SetBool(animBoolName, true);
        }

        /// <summary>
        /// 每帧更新时调用
        /// </summary>
        public virtual void Update()
        {}

        /// <summary>
        /// 物理更新时调用
        /// </summary>
        public virtual void FixedUpdate()
        {}

        /// <summary>
        /// 退出状态时调用
        /// </summary>
        public virtual void Exit()
        {
            animator.SetBool(animBoolName, false);
        }
    }
}